package method;

import java.util.Scanner;

public class test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true){
            System.out.println("请输入需要操作的第一个数");
            int num1 = scanner.nextInt();
            System.out.println("请输入运算符号+，-，*，/");
            String x = scanner.next();
            System.out.println("请输入需要操作的第一个数");
            int num2 = scanner.nextInt();
            switch (x){
                case "+":
                    System.out.println("结果为"+add(num1,num2));
                    break;
                case "-":
                    System.out.println("结果为"+subtract(num1, num2));
                    break;
                case "*":
                    System.out.println("结果为"+multiply(num1, num2));
                    break;
                case "/":
                    System.out.println("结果为"+divide(num1, num2));
                    break;
            }
        }
    }

    //加法
    public static int add(int a,int b){
        return a+b;
    }

    //减法
    public static int subtract(int a,int b){
        return a-b;
    }

    //乘法
    public static int multiply(int a,int b){
        return a*b;
    }

    //除法
    public static int divide(int a,int b){
        return a/b;
    }
}
